﻿/*
 * Erstellt mit SharpDevelop.
 * Benutzer: Kai Patrick
 * Datum: 31.03.2008
 * Zeit: 18:33
 * 
 * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
 */

using System;
using Microsoft.Scripting;
using Irony.Compiler;

namespace Gamadus.Engine.Compiler.Ast
{
	/// <summary>
	/// Description of GmlNode.
	/// </summary>
	public class GmlNode
	{
		public SourceSpan Span;
		
		public GmlNode(AstNode node)
		{
			Microsoft.Scripting.SourceLocation start = ConvertLocation(node.Location);
			Microsoft.Scripting.SourceLocation end = new Microsoft.Scripting.SourceLocation(start.Index+1, start.Line, start.Column);
			Span = new SourceSpan(start, end);
		}
		
		public GmlNode()
		{
			
		}
		
		
//		AstNode NextNode(AstNode node)
//		{
//			bool next = false;
//			if(node.Parent == null)
//				return node;
//			foreach(AstNode child in node.Parent.ChildNodes)
//			{
//				if(child == node)
//					next = true;
//				else if(next)
//					return child;
//			}
//			return NextNode(node.Parent);
//		}
		
		Microsoft.Scripting.SourceLocation ConvertLocation(Irony.Compiler.SourceLocation loc)
		{
			return new Microsoft.Scripting.SourceLocation(loc.Position, loc.Line+1, loc.Column+1);
		}
		
	}
}
